package crp.services.api.graphql.models;

import crp.core.portal.domain.models.PortalBannerEntity;
import com.qwlabs.storage.models.StorageObject;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Id;
import org.eclipse.microprofile.graphql.Ignore;
import org.eclipse.microprofile.graphql.Type;

import javax.validation.constraints.NotNull;

@Type("PortalBanner")
@Builder
@Getter
@AllArgsConstructor
public class PortalBannerPayload {
    @Id
    @NotNull
    private final String id;
    private final String referenceUrl;
    @Ignore
    private final StorageObject cover;

    public static PortalBannerPayload of(PortalBannerEntity entity) {
        return PortalBannerPayload.builder()
                .id(entity.getId())
                .referenceUrl(entity.getReferenceUrl())
                .cover(entity.getCover())
                .build();
    }
}
